<?php
	$id_lichhoc = '';
	if(!empty($this->arrParam['id_lichhoc'])){
		$id_lichhoc = '/id_lichhoc/' . $this->arrParam['id_lichhoc'];
	}
	$id_diadiemhoc = '';
	if(!empty($this->arrParam['id_diadiemhoc'])){
		$id_diadiemhoc = '/id_diadiemhoc/' . $this->arrParam['id_diadiemhoc'];
	}
	$id_phonghoc = '';
	if(!empty($this->arrParam['id_phonghoc'])){
		$id_phonghoc = '/id_phonghoc/' . $this->arrParam['id_phonghoc'];
	}
	$thoigian = '';
	if(!empty($this->arrParam['thoigian'])){
		$thoigian = '/thoigian/' . $this->arrParam['thoigian'];
	}
	$thu = '';
	if(!empty($this->arrParam['thu'])){
		$thu = '/thu/' . $this->arrParam['thu'];
	}
	$linkSlbDiadiemhoc 		= $this->baseUrl($this->currentController . '/ajax-lichhoc'.$id_lichhoc.$thoigian.$thu.'/id_diadiemhoc/');
	$this->Diadiemhoc[0] 	= 'Chọn địa điểm';
	$slbDiadiemhoc			= $this->formSelect ( 'id_diadiemhoc', $this->arrParam['id_diadiemhoc'], array ('onchange'=>"OnSubmitFormAjax('" .$linkSlbDiadiemhoc ."', 'listLichhoc', this)"), $this->Diadiemhoc );
	
	$linkSlbPhonghoc 		= $this->baseUrl($this->currentController . '/ajax-lichhoc'.$id_lichhoc.$thoigian.$thu.'/id_diadiemhoc/' . $this->arrParam['id_diadiemhoc'] . '/id_phonghoc/');
	$this->Phonghoc[0] 		= 'Chọn phòng học';
	$slbPhonghoc			= $this->formSelect ( 'id_phonghoc', $this->arrParam['id_phonghoc'], array ('onchange'=>"OnSubmitFormAjax('" .$linkSlbPhonghoc ."', 'listLichhoc', this)"), $this->Phonghoc );
	
	$linkSlbThoigian 		= $this->baseUrl($this->currentController . '/ajax-lichhoc' . $id_lichhoc.$id_diadiemhoc.$id_phonghoc.$thu. '/thoigian/');
	$optionThoigian			= array(
								'0' => 'Chọn thời gian',
								'1' => 'Sáng',
								'2' => 'Chiều',
								'3' => 'Tối'
							);
	$slbThoigian			= $this->formSelect ( 'thoigian', $this->arrParam['thoigian'], array ('onchange'=>"OnSubmitFormAjax('" .$linkSlbThoigian ."', 'listLichhoc', this)"), $optionThoigian );
	
	$linkSlbThu 			= $this->baseUrl($this->currentController . '/ajax-lichhoc' . $id_lichhoc.$id_diadiemhoc.$id_phonghoc.$thoigian. '/thu/');
	$optionThu				= array('0' => 'Chọn thứ', '2' => 'Thứ 2', '3' => 'Thứ 3', '4' => 'Thứ 4', '5' => 'Thứ 5', '6' => 'Thứ 6', '7' => 'Thứ 7', '8' => 'Chủ nhật');
	$slbThu					= $this->formSelect ( 'thu', $this->arrParam['thu'], array ('onchange'=>"OnSubmitFormAjax('" .$linkSlbThu ."', 'listLichhoc', this)"), $optionThu );

	$strSearchRight = $slbThoigian . ' ' . $slbThu . ' ' . $slbDiadiemhoc . ' ' . $slbPhonghoc;
?>
<script type="text/javascript">
	function OnSubmitFormAjax(linkAjax, idDiv, idItem){
		$('#' + idDiv).load(linkAjax + $(idItem).val());
	}
</script>
<div class="formList goc5" style="border: 1px solid #efefef;">
	<div class="appTop goct5">
		<div class="block_filter">
			<div class="fl">
				<div class="listSearch">
					<span class="title">Danh sách phòng học còn trống</span>
					<div class="clr"></div>			
				</div>
			</div>
			<div class="fr">
				<div class="listSelect">
					<?php echo $strSearchRight;?>
					<div class="clr"></div>
				</div>
			</div>
			<div class="clr"></div>
		</div>
	</div>
	<div class="appBody">
		<table class="tblList">
			<tr>
				<th width="20">#</th>
				<th width="80">Buổi</th>
				<th width="100">Thời gian</th>
				<th width="80">Thứ</th>
				<th width="120">Phòng học</th>
				<th>Địa điểm</th>
				<th width="70">Control</th>
			</tr>
			<?php
			foreach ($this->Items as $key => $val){ 
				$id 			= $val['id'];
				$thu			= $val['thu'];
				$gio_tu			= $val['gio_tu'];
				$phut_tu		= $val['phut_tu'];
				$gio_den		= $val['gio_den'];
				$phut_den		= $val['phut_den'];
				$phonghoc_name	= $val['phonghoc_name'];
				$diadiemhoc_name= $val['diadiemhoc_name'];
				$order 			= $this->formText('order[' . $val['id'] . ']', $val['order'], array('style'=>'width: 30px; text-align: center;'));
				$status 		= $val['status'];
				
				$buoi   = 'Sáng';
				if(($val['gio_tu'] >= 12) && ($val['gio_tu'] < 18)){
					$buoi = 'Chiều';
				}
				if($val['gio_tu'] >= 18){
					$buoi = 'Tối';
				}
					
				$cid 			= $this->formCheckbox('cid[]',$val['id']);
				$classRow = 'row1';
				if($key % 2 == 0)
					$classRow = '';
			?>
			<tr class="<?php echo $classRow;?>" id="danhsach_<?php echo $id;?>">
				<td align="center"><?php echo $key + 1;?></td>
				<td align="center" id="buoi"><?php echo $buoi;?></td>
				<td align="right" id="thoigian">
					<?php echo $gio_tu . 'h' . $phut_tu . ' - ' . $gio_den . 'h' . $phut_den;?>
				</td>
				<td align="right" id="thu"><?php echo $thu;?></td>
				<td align="center" id="phonghoc"><?php echo $phonghoc_name;?></td>
				<td align="left" id="diadiem"><?php echo $diadiemhoc_name;?></td>
				<td align="center"><a href="javascript:void(0)" onclick="addLichhoc(<?php echo $id;?>)">Chọn</a></td>
			</tr>
			<?php
			} 
			?>
		</table>
		<div class="phanTrangAjax">
			<?php
				$strPage = '';
				if(!empty($this->arrParam['id_diadiemhoc'])){
					$strPage .= '/id_diadiemhoc/' . $this->arrParam['id_diadiemhoc'];
				}
				if(!empty($this->arrParam['id_phonghoc'])){
					$strPage .= '/id_phonghoc/' . $this->arrParam['id_phonghoc'];
				}
				$currentUrl = $this->baseUrl($this->currentController . '/ajax-lichhoc' . $strPage);
				echo $this->paginationControl($this->paginator,'Sliding','pagination-ajax.phtml',array('currentUrl'=>$currentUrl, 'options' => array('idLoad' => 'listLichhoc'))); 
			?>
		</div>
	</div>
</div>